import http from './http.js'
// 获取我的信息
function getMe(){
    const url = `/api/login-user/info`;
    return http.get(url);
}
// 获取验证码
function getYanZheng(tel){
    const url = `/api/short-message/vcode/${tel}`;
    return http.get(url)
}
// 注册
function register(loginName,userName,password,phonenumber,code){
    const url = `/api/registry`;
    let formdata = new FormData()
    console.log(phonenumber);
    formdata.append('loginName',loginName)
    formdata.append('userName',userName)
    formdata.append('password',password)
    formdata.append('phonenumber',phonenumber)
    formdata.append('code',code)
    return http.post(url,formdata)
}
// 忘记密码
function forgetPwd(loginName,password,phonenumber,code){
    const url = `/api/password/forget`;
    let formdata = new FormData()
    formdata.append('loginName',loginName)
    formdata.append('password',password)
    formdata.append('phonenumber',phonenumber)
    formdata.append('code',code)
    return http.post(url,formdata)
}
// 退出登录
function logout(){
    const url = `/api/logout`;
    return http.get(url)
}
// 修改信息
function changeMsg(userName,email,phonenumber){
    const url = `/api/system/user/profile/update`
    let formdata = new FormData()
    formdata.append('userName',userName)
    formdata.append('email',email)
    formdata.append('phonenumber',phonenumber)
    return http.post(url,formdata)
}
// 修改头像
function subHeadImg(avatarfile){
    const url = `/api/system/user/profile/update/avatar/nos`;
    let formdata = new FormData()
    formdata.append('avatarfile',avatarfile)
    return http.post(url,formdata)
}
export {
    getMe,
    getYanZheng,
    register,
    forgetPwd,
    logout,
    changeMsg,
    subHeadImg
}